#pragma once

typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; // windbgkd

typedef LONG NTSTATUS;

typedef struct _UNICODE_STRING {
    USHORT Length;
    USHORT MaximumLength;
#ifdef MIDL_PASS
    [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
#else // MIDL_PASS
    PWSTR  Buffer;
#endif // MIDL_PASS
} UNICODE_STRING;
typedef UNICODE_STRING *PUNICODE_STRING;

typedef enum _SECTION_INHERIT {
	ViewShare = 1,
		ViewUnmap = 2
} SECTION_INHERIT;

typedef struct _OBJECT_ATTRIBUTES {
    ULONG Length;
    HANDLE RootDirectory;
    PUNICODE_STRING ObjectName;
    ULONG Attributes;
    PVOID SecurityDescriptor;        // Points to type SECURITY_DESCRIPTOR
    PVOID SecurityQualityOfService;  // Points to type SECURITY_QUALITY_OF_SERVICE
} OBJECT_ATTRIBUTES;
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;



//
// Global NT Functions
//


BOOLEAN LocateNtdllEntryPoints();

NTSTATUS BBNtUnmapViewOfSection(IN HANDLE ProcessHandle,IN PVOID  BaseAddress);

NTSTATUS BBNtMapViewOfSection(
	  IN HANDLE  SectionHandle,
	  IN HANDLE  ProcessHandle,
	  IN OUT PVOID  *BaseAddress,
	  IN ULONG  ZeroBits,
	  IN ULONG  CommitSize,
	  IN OUT PLARGE_INTEGER  SectionOffset,	/* optional */
	  IN OUT PULONG  ViewSize,
	  IN SECTION_INHERIT  InheritDisposition,
	  IN ULONG  AllocationType,
	  IN ULONG  Protect
);

PHYSICAL_ADDRESS BBMmGetPhysicalAddress(IN PVOID BaseAddress);

VOID BBRtlInitUnicodeString(
	IN OUT PUNICODE_STRING DestinationString,
	IN PCWSTR SourceString);

NTSTATUS BBNtOpenSection(
	OUT PHANDLE SectionHandle,
	IN ACCESS_MASK DesiredAccess,
	IN POBJECT_ATTRIBUTES ObjectAttributes);

ULONG BBRtlNtStatusToDosError(IN NTSTATUS Status);

//////////////////////////////////////////////////////////////////////////

